package com.hanoi.wiki.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.hanoi.wiki.model.json.CategoryJson;

@Entity
@Table(name = "CATEGORY")
public class Category implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public Category() {
		
	}
	
	public Category(CategoryJson json) {
		this.categoryName 	= json.getCategoryName();
		this.description 	= json.getDescription();
		this.priority		= json.getPriority();
		this.status			= json.getStatus();
	}
	
	@Id
	@Column(name = "ID")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Integer id;

	@Column(name = "CATEGORY_NAME", length = 200, unique = true, nullable = false)
	private String categoryName;

	@Column(name = "STATUS")
	private Integer status;

	@Column(name = "PRIORITY")
	private Integer priority;

	@Column(name = "DESCRIPTION", length = 2000)
	private String description;

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "CAT_CATTYPE", joinColumns = { @JoinColumn(name = "CAT_ID")}, inverseJoinColumns = {@JoinColumn(name = "CAT_TYPE_ID")})
	private List<CategoryType> categoryTypes;

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "PLACE_CATEGORY", joinColumns = { @JoinColumn(name = "CAT_ID") }, inverseJoinColumns = { @JoinColumn(name = "PLACE_ID") })
	private List<Places> places;

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "PLACEINQUEUED_CATEGORY", joinColumns = { @JoinColumn(name = "CAT_ID") }, inverseJoinColumns = { @JoinColumn(name = "PLACE_IN_QUEUED_ID") })
	private List<PlacesInQueued> placesInQueueds;

	public List<Places> getPlaces() {
		return places;
	}

	public void setPlaces(List<Places> places) {
		this.places = places;
	}

	public List<PlacesInQueued> getPlacesInQueueds() {
		return placesInQueueds;
	}

	public void setPlacesInQueueds(List<PlacesInQueued> placesInQueueds) {
		this.placesInQueueds = placesInQueueds;
	}

	public List<CategoryType> getCategoryTypes() {
		return categoryTypes;
	}

	public void setCategoryTypes(List<CategoryType> categoryTypes) {
		this.categoryTypes = categoryTypes;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Integer getPriority() {
		return priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
}
